package cn.gson.springboot.model.pjos;

import javax.persistence.*;
import java.sql.Date;
import java.util.Collection;
import java.util.List;
import java.util.Objects;

@Entity
public class Products {
    private int prId;//id
    private String prName;//产品名称
    private String prModel;//产品型号
    private Date prData;//入库日期
    private String prUnit;//计数单位
    private Integer prState;//是否可出售
    private Collection<Productimgs> productimgsByPrId;//产品图片
    private Productbrand productbrandByPbId;//产品品牌
    private Productcategory productcategoryByPcId;//产品类型
    private Productside productsideByPrsId;//副标
    private List<Productside> productsideList;//

    @OneToMany(mappedBy = "products")
    public List<Productside> getProductsideList() {
        return productsideList;
    }

    public void setProductsideList(List<Productside> productsideList) {
        this.productsideList = productsideList;
    }

    @Id
    @Column(name = "Pr_id")
    @GeneratedValue(strategy = GenerationType.IDENTITY,generator = "seq")
    public int getPrId() {
        return prId;
    }

    public void setPrId(int prId) {
        this.prId = prId;
    }

    @Basic
    @Column(name = "Pr_name")
    public String getPrName() {
        return prName;
    }

    public void setPrName(String prName) {
        this.prName = prName;
    }

    @Basic
    @Column(name = "Pr_model")
    public String getPrModel() {
        return prModel;
    }

    public void setPrModel(String prModel) {
        this.prModel = prModel;
    }

    @Basic
    @Column(name = "Pr_data")
    public Date getPrData() {
        return prData;
    }

    public void setPrData(Date prData) {
        this.prData = prData;
    }

    @Basic
    @Column(name = "Pr_unit")
    public String getPrUnit() {
        return prUnit;
    }

    public void setPrUnit(String prUnit) {
        this.prUnit = prUnit;
    }

    @Basic
    @Column(name = "Pr_state")
    public Integer getPrState() {
        return prState;
    }

    public void setPrState(Integer prState) {
        this.prState = prState;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Products products = (Products) o;
        return prId == products.prId &&
                Objects.equals(prName, products.prName) &&
                Objects.equals(prModel, products.prModel) &&
                Objects.equals(prData, products.prData) &&
                Objects.equals(prUnit, products.prUnit) &&
                Objects.equals(prState, products.prState);
    }

    @Override
    public int hashCode() {
        return Objects.hash(prId, prName, prModel, prData, prUnit, prState);
    }

    @OneToMany(mappedBy = "productsByPrId")
    public Collection<Productimgs> getProductimgsByPrId() {
        return productimgsByPrId;
    }

    public void setProductimgsByPrId(Collection<Productimgs> productimgsByPrId) {
        this.productimgsByPrId = productimgsByPrId;
    }

    @ManyToOne
    @JoinColumn(name = "Pb_id", referencedColumnName = "Pb_id")
    public Productbrand getProductbrandByPbId() {
        return productbrandByPbId;
    }

    public void setProductbrandByPbId(Productbrand productbrandByPbId) {
        this.productbrandByPbId = productbrandByPbId;
    }

    @ManyToOne
    @JoinColumn(name = "Pc_id", referencedColumnName = "Pc_id")
    public Productcategory getProductcategoryByPcId() {
        return productcategoryByPcId;
    }

    public void setProductcategoryByPcId(Productcategory productcategoryByPcId) {
        this.productcategoryByPcId = productcategoryByPcId;
    }

    @ManyToOne
    @JoinColumn(name = "Prs_id", referencedColumnName = "Prs_id")
    public Productside getProductsideByPrsId() {
        return productsideByPrsId;
    }

    public void setProductsideByPrsId(Productside productsideByPrsId) {
        this.productsideByPrsId = productsideByPrsId;
    }
}
